package org.xzx.shop_api.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.xzx.shop_api.entity.Areas;
import org.xzx.shop_api.mapper.AreasMapper;
import org.xzx.shop_api.service.AreasService;

import java.util.List;
@Service
public class AreasServiceImpl implements AreasService {
    @Autowired
    private AreasMapper areasMapper;

    @Override
    public List<Areas> getProvinces() {
        return areasMapper.selectByParentIdAndLevel(0,1);
    }

    @Override
    public List<Areas> getCitiesByProvinceld(int provinceId) {
        return areasMapper.selectByParentIdAndLevel(provinceId,2);
    }

    @Override
    public List<Areas> getAreasByCityId(int cityId) {
        return areasMapper.selectByParentIdAndLevel(cityId,3);
    }
}
